package com.ruoyi.chengji.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.pingjiao.domain.Resource;
import com.ruoyi.pingjiao.service.ResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("score/resource")
public class ResourceController extends BaseController {
    @Autowired
    private ResourceService resourceService;

    @GetMapping("list")
    public TableDataInfo list(Resource resource){
        startPage();
        return getDataTable(resourceService.list(resource));
    }

    @PostMapping("add")
    public AjaxResult add(@RequestBody Resource resource){
        return toAjax(resourceService.add(resource));
    }

    @PutMapping("update")
    public AjaxResult update(@RequestBody Resource resource){
        return toAjax(resourceService.updateInfo(resource));
    }

    @DeleteMapping("/delete/{id}")
    public AjaxResult delete(@PathVariable Integer id){
        return toAjax(resourceService.delete(id));
    }

    @GetMapping("{id}")
    public AjaxResult getInfo(@PathVariable Integer id){
        return AjaxResult.success(resourceService.getResourceInfo(id));
    }
}
